import * as moment from "moment";
import { SetMetadata } from '@nestjs/common';
/**
 * 日期格式化属性装饰器
 * @param options: { format: string(格式化方式) }
 * @returns 
 */
export function DateFormat(options: { format: string; }): (target: any, propertyKey:  string | symbol) => void {
    return (target: any, propertyKey: string | symbol) => {
        let value: number| string;
        Object.defineProperty(target, propertyKey, {
          get: () => {
            const val = moment(value).format(options.format);
            return val;
          },
          set: (val) => {
            value = val;
            console.log('----------', val)
          },
        });
    }
}
export const Roles = (...args: string[]) => SetMetadata('roles', args);